package com.yufuchang;

import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by yufuchang on 2020/8/12.
 */
@RestController
public class GetControllerAdviceParamController {

    @GetMapping("/get_by_key")
    public String getInfoByKey(@ModelAttribute("msg") String msg, @ModelAttribute("map")HashMap<String,String> map){
        return msg + "   " + map.get("name") +"   "+ map.get("age");
    }

    @GetMapping("/get_by_model")
    public String getInfoByModel(Model model){
        Map<String,Object> modelMap = model.asMap();
        String msg = (String) modelMap.get("msg2");
        Map<String,String> map = (Map<String, String>) modelMap.get("map2");
        return msg + map.get("name") + map.get("age");
    }
}
